<div>
	Here is a simple AJAX Request.
</div>
<div id="subButton"></div>
<textarea id="log" cols="40" rows="10"></textarea>

<script type="text/javascript" src="../../lib/ext/adapter/ext/ext-base.js"></script>
 
<script type="text/javascript">
	function doJSON(stringData) {
		try {
			var jsonData = Ext.util.JSON.decode(stringData);
			Ext.MessageBox.alert('Success', 'Decode of stringData OK<br />jsonData.date = ' + jsonData.date);
		}
		catch (err) {
			Ext.MessageBox.alert('ERROR', 'Could not decode ' + stringData);
		}
	}
 
	function doAjax() {
		Ext.Ajax.request({
			url : 'http://localhost:9998/xpathsearch' , 
			params : { action : '' },
			method: 'GET',
			success: function ( result, request) { 
				var textArea = Ext.get('log').dom;
				textArea.value += result.responseText + "\n"; 
				//Ext.MessageBox.alert('Success', 'Data return from the server: '+ result.responseText); 		
				doJSON(result.responseText);
			},
			failure: function ( result, request) { 
				Ext.MessageBox.alert('Failed', 'Successfully posted form: '+result.date); 
			} 
		});
	}
 
	var button = new Ext.Button('subButton', {
		text: 'Click to submit an AJAX Request',
		handler: doAjax
	});
</script>